﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using RCREEE.Library.Entities;

namespace RCREEE.Service
{
    public partial class Service
    {
        List<string> errorMessages;

        ApprovedIncentives app=new ApprovedIncentives();
        List<ApprovedIncentives> listapproved=new List<ApprovedIncentives>();
        
        #region approvedIncentive
        [WebMethod]
        public List<ApprovedIncentives> GetApprovedIncentives(int CountryId, int LanguageCode, out List<string> errorMessages)
        {
            errorMessages = new List<string>();

            if (LanguageCode != 1025 && LanguageCode != 1033 && LanguageCode != 1036)
                errorMessages.Add("Invalid Language Code");

            if (CountryId <= 0)
                errorMessages.Add("Please, provide a valid CountryId");

            if (errorMessages.Count > 0)
                return null;


            listapproved = app.WebGetApprovedIncentives(CountryId, LanguageCode);
            if (listapproved != null)
                return listapproved;
            else
                return null;
        }

        [WebMethod]
        public ApprovedIncentives GetOneApprovedIncentives(int CountryId, int LanguageCode, int ItemId, out List<string> errorMessages)
        {
            ApprovedIncentives Approved = new ApprovedIncentives();
            errorMessages = new List<string>();

            if (LanguageCode != 1025 && LanguageCode != 1033 && LanguageCode != 1036)
                errorMessages.Add("Invalid Language Code");

            if (CountryId <= 0)
                errorMessages.Add("Please, provide a valid CountryId");
            if (ItemId <= 0)
                errorMessages.Add("Please, provide a valid ItemId");
            if (errorMessages.Count > 0)
                return null;

            Approved = app.WebGetOneApprovedIncentives(CountryId, LanguageCode, ItemId);
            if (Approved != null)
                return Approved;
            else
                return null;
        }
        [WebMethod]
        public bool UpdateApprovedIncentives(List<ApprovedIncentives> Approved, out List<string> errorMessages)
        {
            errorMessages = new List<string>();

            bool saveSuccessful = false;

            saveSuccessful = app.UpdateApprovedIncentives(Approved);

            if (!saveSuccessful)
                errorMessages.Add("An error has occured during saving ApprovedIncentive data");

            return saveSuccessful;
        }

        #endregion

        #region project


        Project objProject = new Project();
        List<Project> lstProject = new List<Project>();


        [WebMethod]
        public List<Project> SelectAllstProject(int LanguageCode, int EntityId, out List<string> errorMessages)
        {
            errorMessages = new List<string>();

            if (LanguageCode != 1025 && LanguageCode != 1033 && LanguageCode != 1036)
                errorMessages.Add("Invalid Language Code");

            if (EntityId <= 0)
                errorMessages.Add("Please, provide a valid EntityId");
            lstProject = objProject.SelectAllProjectweb(LanguageCode, EntityId);

            if (lstProject != null)
                return lstProject;
            else
                return null;

        }
        [WebMethod]
        public List<Project> SelectAllstProjectByCountry(int LanguageCode, int CountryId, int EntityId, out List<string> errorMessages)
        {

            errorMessages = new List<string>();

            if (LanguageCode != 1025 && LanguageCode != 1033 && LanguageCode != 1036)
                errorMessages.Add("Invalid Language Code");
            if(CountryId<=0)
                errorMessages.Add("Please, provide a valid CountryId");
            if (EntityId <= 0)
                errorMessages.Add("Please, provide a valid EntityId");
            lstProject = objProject.SelectAllprojectByCountryweb(LanguageCode, CountryId, EntityId);

            if (lstProject != null)
                return lstProject;
            else
                return null;
        }
        [WebMethod]
        public Project SelectprojectbyId(int LanguageCode, int ProjectId, int Record, out List<string> errorMessages)
        {

            errorMessages = new List<string>();

            if (LanguageCode != 1025 && LanguageCode != 1033 && LanguageCode != 1036)
                errorMessages.Add("Invalid Language Code");
            if (ProjectId <= 0)
                errorMessages.Add("Please, provide a valid ProjectId");
            if (Record <= 0)
                errorMessages.Add("Please, provide a valid Record");

            objProject = objProject.SelectprojectbyIdweb(LanguageCode, ProjectId, Record);

            if (objProject != null)
                return objProject;
            else
                return null;
        }
        [WebMethod]
        public bool InsertProject(Project project, out List<string> errorMessages)
        {
            errorMessages = new List<string>();

            bool saveSuccessful = false;
            saveSuccessful = objProject.InsertProject(project);

            if (!saveSuccessful)
                errorMessages.Add("An error has occured during saving Project data");
           
                return saveSuccessful;
        }
        [WebMethod]
        public bool UpdateProject(Project project)
        {
            errorMessages = new List<string>();

            bool saveSuccessful = false;
            saveSuccessful = objProject.UpdateProject(project);

            if (!saveSuccessful)
                errorMessages.Add("An error has occured during Updateing Project data");

            return saveSuccessful;
        }
        [WebMethod]
        public bool Deleteproject(Project project)
        {
            errorMessages = new List<string>();

            bool saveSuccessful = false;
            saveSuccessful = objProject.Deleteproject(project);

            if (!saveSuccessful)
                errorMessages.Add("An error has occured during Deleteing Project data");

            return saveSuccessful;
        }
        #endregion
      
    }
}